home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / term43-source.lha / Extras / Source / gtlayout-Source.lha / LTP_DrawGroup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-26  |  8.4 KB  |  245 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1994 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. VOID __regargs
  10. LTP_DrawGroup(LayoutHandle *Handle,ObjectNode *Group)
  11. {
  12.     ObjectNode    *Node;
  13.     LONG         i;
  14.     ULONG         page;
  15.  
  16.     if(Group -> Label || Group -> Special . Group . Frame)
  17.         LTP_DrawLabel(Handle,Group);
  18.  
  19.     SCANPAGE(Group,Node,page)
  20.     {
  21.         switch(Node -> Type)
  22.         {
  23.             case BUTTON_KIND:
  24.  
  25.                 if(Handle -> ReturnKey == Node)
  26.                     LTP_DrawBevelBox(Handle,Node);
  27.  
  28.                 break;
  29. #ifdef DO_GAUGE_KIND
  30.             case GAUGE_KIND:
  31.             {
  32.                 LONG Percent = Node -> Current;
  33.  
  34.                 Node -> Current = 0;
  35.  
  36.                 LTP_DrawGauge(Handle,Node,Percent,TRUE);
  37.  
  38.                 break;
  39.             }
  40. #endif
  41.             case GROUP_KIND:
  42.  
  43.                 if(Node -> Label)
  44.                     LTP_DrawLabel(Handle,Node);
  45.  
  46.                 LTP_DrawGroup(Handle,Node);
  47.  
  48.                 break;
  49.  
  50.             case XBAR_KIND:
  51.             {
  52.                 WORD Top = Node -> Top + ((Node -> Height + 1) / 2) - 1;
  53.  
  54.                 LockLayerRom(Handle -> RPort . Layer);
  55.  
  56.                 if(Node -> Special . Bar . FullSize)
  57.                 {
  58.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  59.                     Move(&Handle -> RPort,Handle -> Window -> BorderLeft,Top);
  60.                     Draw(&Handle -> RPort,Handle -> Window -> Width - (Handle -> Window -> BorderRight + 1),Top);
  61.  
  62.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  63.                     Move(&Handle -> RPort,Handle -> Window -> BorderLeft,Top + 1);
  64.                     Draw(&Handle -> RPort,Handle -> Window -> Width - (Handle -> Window -> BorderRight + 1),Top + 1);
  65.                 }
  66.                 else
  67.                 {
  68.                     if(Node -> Special . Bar . Parent -> Label)
  69.                     {
  70.                         LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  71.                         Move(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + 2 * Handle -> GlyphWidth,Top + 1);
  72.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + 2 * Handle -> GlyphWidth,Top);
  73.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - (2 * Handle -> GlyphWidth + 1) - 1,Top);
  74.  
  75.                         LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  76.                         Move(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + 2 * Handle -> GlyphWidth + 1,Top + 1);
  77.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - (2 * Handle -> GlyphWidth + 1),Top + 1);
  78.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - (2 * Handle -> GlyphWidth + 1),Top);
  79.                     }
  80.                     else
  81.                     {
  82.                         LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  83.                         Move(&Handle -> RPort,Node -> Special . Bar . Parent -> Left,Top + 1);
  84.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left,Top);
  85.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - 1,Top);
  86.  
  87.                         LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  88.                         Move(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + 1,Top + 1);
  89.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - 1,Top + 1);
  90.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - 1,Top);
  91.                     }
  92.                 }
  93.  
  94.                 UnlockLayerRom(Handle -> RPort . Layer);
  95.  
  96.                 break;
  97.             }
  98.  
  99.             case YBAR_KIND:
  100.             {
  101.                 WORD Left = Node -> Left + ((Node -> Width + 1) / 2) - 1;
  102.  
  103.                 LockLayerRom(Handle -> RPort . Layer);
  104.  
  105.                 if(Node -> Special . Bar . Parent -> Label)
  106.                 {
  107.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  108.                     Move(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + Handle -> RPort . TxHeight + Handle -> InterHeight);
  109.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Handle -> RPort . TxHeight + Handle -> InterHeight);
  110.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - (Handle -> RPort . TxHeight + Handle -> InterHeight + 1) - 1);
  111.  
  112.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  113.                     Move(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + Handle -> RPort . TxHeight + Handle -> InterHeight + 1);
  114.                     Draw(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - (Handle -> RPort . TxHeight + Handle -> InterHeight + 1));
  115.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - (Handle -> RPort . TxHeight + Handle -> InterHeight + 1));
  116.                 }
  117.                 else
  118.                 {
  119.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  120.                     Move(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top);
  121.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top);
  122.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1 - 1);
  123.  
  124.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  125.                     Move(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + 1);
  126.                     Draw(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1);
  127.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1);
  128.                 }
  129.  
  130.                 UnlockLayerRom(Handle -> RPort . Layer);
  131.  
  132.                 break;
  133.             }
  134.  
  135.             case FRAME_KIND:
  136.  
  137.                 if(Node -> Special . Frame . DrawBox)
  138.                     LTP_DrawBevelBox(Handle,Node);
  139.  
  140.                 if(Node -> Special . Frame . RefreshHook)
  141.                 {
  142.                     RefreshMsg Message;
  143.  
  144.                     Message . ID        = Node -> ID;
  145.                     Message . Left        = Node -> Left;
  146.                     Message . Top        = Node -> Top;
  147.                     Message . Width        = Node -> Width;
  148.                     Message . Height    = Node -> Height;
  149.  
  150.                     CallHookPkt(Node -> Special . Frame . RefreshHook,Handle,&Message);
  151.                 }
  152.  
  153.                 // FALL THROUGH TO...
  154.  
  155.             case TAPEDECK_KIND:
  156.  
  157.                 if(Node -> Label)
  158.                 {
  159.                     LTP_SetPens(&Handle -> RPort,Handle -> TextPen,Handle -> BackgroundPen,JAM2);
  160.  
  161.                     switch(Node -> LabelPlace)
  162.                     {
  163.                         case PLACE_LEFT:
  164.  
  165.                             LTP_PrintLabel(Handle,Node,Node -> Left,Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2);
  166.                             break;
  167.  
  168.                         case PLACE_RIGHT:
  169.  
  170.                             LTP_PrintLabel(Handle,Node,Node -> Left + Node -> Width + INTERWIDTH + INTERWIDTH + Node -> LabelWidth,Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2);
  171.                             break;
  172.  
  173.                         case PLACE_ABOVE:
  174.  
  175.                             LTP_PrintLabel(Handle,Node,Node -> Left + (Node -> Width - Node -> LabelWidth) / 2 + INTERWIDTH + Node -> LabelWidth,Node -> Top - (Handle -> RPort . TxHeight + INTERHEIGHT));
  176.                             break;
  177.  
  178.                         case PLACE_BELOW:
  179.  
  180.                             LTP_PrintLabel(Handle,Node,Node -> Left + (Node -> Width - Node -> LabelWidth) / 2 + INTERWIDTH + Node -> LabelWidth,Node -> Top + Node -> Height + INTERHEIGHT);
  181.                             break;
  182.                     }
  183.                 }
  184.  
  185.                 break;
  186.  
  187.             case MX_KIND:
  188.  
  189.                 if(Node -> Label && !V39)
  190.                     LTP_PrintLabel(Handle,Node,Node -> Left,Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2 + 1);
  191.  
  192.                 break;
  193.  
  194.             case LISTVIEW_KIND:
  195.  
  196.                 if(Node -> Special . List . ExtraLabels)
  197.                 {
  198.                     LockLayerRom(Handle -> RPort . Layer);
  199.  
  200.                     LTP_SetPens(&Handle -> RPort,Handle -> TextPen,Handle -> BackgroundPen,JAM2);
  201.  
  202.                     for(i = 0 ; Node -> Special . List . ExtraLabels[i] ; i++)
  203.                     {
  204.                         LONG Len = strlen(Node -> Special . List . ExtraLabels[i]);
  205.  
  206.                         LTP_PlaceText(Handle,Node -> Special . List . ExtraLabels[i],Len,Node -> Left - (TextLength(&Handle -> RPort,Node -> Special . List . ExtraLabels[i],Len) + INTERWIDTH),Node -> Top + 2 + i * Handle -> RPort . TxHeight + Handle -> RPort . TxBaseline);
  207.                     }
  208.  
  209.                     UnlockLayerRom(Handle -> RPort . Layer);
  210.                 }
  211.  
  212.                 if(Node -> Label && Node -> LabelPlace == PLACE_ABOVE && Node -> Special . List . FlushLabelLeft)
  213.                     LTP_PrintLabel(Handle,Node,Node -> Left + 2 + INTERWIDTH + Node -> LabelWidth,Node -> Top - (Handle -> RPort . TxHeight + INTERHEIGHT));
  214.  
  215.                 break;
  216.  
  217.             case BOX_KIND:
  218.  
  219.                 Node -> Special . Box . Parent = Group;
  220.  
  221.                 if(Node -> Special . Box . DrawBox)
  222.                     LTP_DrawBevelBox(Handle,Node);
  223.  
  224.                 LockLayerRom(Handle -> RPort . Layer);
  225.  
  226.                 for(i = 0 ; i < Node -> Lines ; i++)
  227.                 {
  228.                     if(Node -> Special . Box . Labels && Node -> Special . Box . Labels[i])
  229.                     {
  230.                         LONG Len = strlen(Node -> Special . Box . Labels[i]);
  231.  
  232.                         LTP_SetPens(&Handle -> RPort,Handle -> TextPen,Handle -> BackgroundPen,JAM2);
  233.                         LTP_PlaceText(Handle,Node -> Special . Box . Labels[i],Len,Node -> Left - (TextLength(&Handle -> RPort,Node -> Special . Box . Labels[i],Len) + INTERWIDTH),Node -> Top + 2 + i * Handle -> RPort . TxHeight + Handle -> RPort . TxBaseline);
  234.                     }
  235.  
  236.                     LTP_PrintBoxLine(Handle,Node,i);
  237.                 }
  238.  
  239.                 UnlockLayerRom(Handle -> RPort . Layer);
  240.  
  241.                 break;
  242.         }
  243.     }
  244. }
  245.